<?php
class Module_Select {
	public function getMainModule(){
		$sql = "select * from `zjx_module_admin` where `z_belong`<1 order by z_belong,z_grade";
		$return = array();
		$ret = mysql_query($sql);
		while ($row = mysql_fetch_array($ret)){
			$return[] = $row;
		}
		
		return $return;
	}
	public function getAllModule(){
		$sql = "select * from `zjx_module_admin`  order by z_belong,z_grade";
		$return = array();
		$ret = mysql_query($sql);
		while ($row = mysql_fetch_array($ret)){
			$return[] = $row;
		}
		
		return $return;
	}
	public function getSonModuleById($id){
		$sql = "select * from `zjx_module_admin` where `z_belong`=".$id." order by z_belong,z_grade";
		$return = array();
		$ret = mysql_query($sql);
		while ($row = mysql_fetch_array($ret)){
			$return[] = $row;
		}
		
		return $return;
	}
	
	public function getModuleInfoById($id){
		$sql = "select * from `zjx_module_admin` where `z_id`=".$id." order by z_belong,z_grade";
		$return = array();
		$ret = mysql_query($sql);
		while ($row = mysql_fetch_array($ret)){
			$return[] = $row;
		}
		
		return $return;
	}
	public function getContentModInfoByUrl($url){
		$sql = "select * from `zjx_module_admin` where `z_url`='".$url."' order by z_belong,z_grade";
		$return = array();
		$ret = mysql_query($sql);
		while ($row = mysql_fetch_array($ret)){
			$return[] = $row;
		}
		
		return $return;
	}
	
	public function selectModconById($mid){
		return Db_Mysql::find('zjx_content','c_mid='.$mid);
	}
	public function getArticleInfoById($id){
		return Db_Mysql::find('zjx_article','a_id='.$id);
	}
	public function getProductInfoById($id){
		return Db_Mysql::find('zjx_product','p_id='.$id);
	}
	public function getMsgInfoById($id){
		return Db_Mysql::find('zjx_msgboard','m_id='.$id);
	}
	public function getHaveConMid(){
		$mod = Db_Mysql::findAll('zjx_content','','c_mid mid');
		$ret = array();
		if(is_array($mod) && count($mod)>0){
			foreach ($mod as $v) {
				$ret[] = $v['mid'];
			}
		}
		return $ret;
	}
	public function checkMidInContent($mid){
		$sql = "select count(*) num from `zjx_content` where c_mid=".$mid;
		$ret = mysql_query($sql);
		$row = mysql_fetch_array($ret);
		return $row['num'];
	}
	public function getAllContentInfo(){
		return Db_Mysql::findAll('zjx_content');
	}
	public function getAllTitInfo(){
		return Db_Mysql::findAll('zjx_article','','*','a_mid');
	}
	public function getAllProductInfo(){
		return Db_Mysql::findAll('zjx_product','','*','p_mid');
	}
	public function getAllAttrByPid($pid){
		return Db_Mysql::findAll('zjx_proattr','a_pid='.$pid,'*','a_grade');
	}
	public function getAllMsgInfo(){
		return Db_Mysql::findAll('zjx_msgboard');
	}
	public function getModarr($where){
		$modarr = Db_Mysql::findAll('zjx_module_admin',$where,'z_id mid,z_name zn');
		$ret = array();
		if(is_array($modarr)&& count($modarr)>0){
			foreach ($modarr as $v){
				$ret[$v['mid']] = $v['zn'];
			}
		}
		return $ret;
	}
	public function getAllLinks(){
		$sql = 'select * from `zjx_links` order by `l_order`';
		$return = array();
		$ret = mysql_query($sql);
		while ($row = mysql_fetch_array($ret)){
			$return[]=$row;
		}
		return $return;
	}
/**
 * 获取首页显示的大图片
 */	
		public function getWebAllInfo(){
			return Db_Mysql::find('zjx_basicinfo');
		}
}